from PIL import Image,ImageDraw,ImageFont
import os
i1 = 'wangyi/'+ os.listdir('wangyi')[0]
base_img = Image.open(i1, 'r')
print (base_img.size, base_img.mode)  #(320, 160) RGB

text='嘉 卧 秋'
im = Image.new("RGB", (320, 30), (255, 255, 255))
dr = ImageDraw.Draw(im)
font = ImageFont.truetype(os.path.join("fonts", "simsun.ttc"), 20)
dr.text((130,8), text, font=font, fill="#000000")
im.save("wangyi/words.jpg")
i2 = 'wangyi/words.jpg'
bg_img = Image.open(i2, 'r')
# 创建空白长图
result = Image.new('RGB', (320,190))

# 拼接图片 (0, 0), (base_img.width, base_img.height) 起始点的横坐标，起始点的纵坐标
result.paste(base_img, (0, 0, base_img.width, base_img.height))
result.paste(bg_img, (0, base_img.height, bg_img.width, base_img.height + bg_img.height))

result.save('wangyi/result.jpg')

